package cn.edu.hunau.java.week03.day03;

import org.junit.Test;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class HashTest {

    @Test
    public void testHash(){
        Map<Integer,String> map=new HashMap<>();
        map.put(1,"张三");
        map.put(2,"李四");
        map.put(3,"王五");
        map.put(4,"赵六");
        map.put(5,"孙七");
        System.out.println(map);
        System.out.println(map.size());
        System.out.println(map.isEmpty());
        System.out.println(map.containsKey(2));
        System.out.println(map.containsValue("张麻子"));
        String value=map.get(4);
        System.out.println(value);

        Set<Integer> keySet=map.keySet();
        for(Integer key:keySet){
            String v=map.get(key);
            System.out.println(key+"--"+v);
        }

        Set<Map.Entry<Integer,String>> entrySet=map.entrySet();
        for(Map.Entry<Integer,String> entry:entrySet){
            Integer key=entry.getKey();
            String v=entry.getValue();
            System.out.println(key+"--"+v);
        }
    }
}
